﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace BacklogParser.Models.Procedural
{
    public class ProceduralData
    {
        public ProceduralData()
        {
            this.step_result = new List<StepResult>();
            this.step_date = new List<StepDate>();
            this.step_text = new List<StepText>();

        }

        public string doc_id { get; set; }

        public string step_code { get; set; }

        public string time_limit { get; set; }

        public string affected_states { get; set; }

        public string gazzete_date { get; set; }

        public string gazzete_num { get; set; }

        public string gazzete_text { get; set; }


        public List<StepResult> step_result { get; set; }

        public List<StepText> step_text { get; set; }

        public List<StepDate> step_date { get; set; }
        public int Index { get; internal set; }
    }

    public class StepText
    {
        public StepText()
        {
        }

        public StepText(XElement stepText, string doc_id)
        {
            this.doc_id = doc_id;
            this.step_text = stepText.Value;
            this.text_type = stepText.Attribute("step-text-type").Value;
        }

        public string doc_id { get; set; }

        public string text_type { get; set; }

        public string step_text { get; set; }
    }

    public class StepResult
    {
        public StepResult()
        {
        }

        public StepResult(XElement x, string documentId)
        {
            this.doc_id = documentId;
            var resultTypeAttr = x.Attribute("step-result-type");
            if(resultTypeAttr != null)
                this.result_type = resultTypeAttr.Value;
            this.step_result = x.Value;
        }

        public string doc_id { get; set; }
        public string Index { get; set; }
        public string step_result { get; set; }

        public string result_type { get; set; }
    }

    public class StepDate
    {
        public StepDate(XElement x, string documentId)
        {
            this.doc_id = documentId;
            this.date_type = x.Attribute("step-date-type").Value;
            this.date = x.Value;
        }

        public string doc_id { get; set; }

        public string date { get; set; }

        public string date_type { get; set; }
    }
}
